﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rappelz.GameServer.Network;

namespace Rappelz.GameServer
{

    public class CreatureAtribute
    {
        public float nCritical;
        public float nCriticalPower;
        public float nAttackPointRight;
        public float nAttackPointLeft;
        public float nDefence;
        public float nBlockDefence;
        public float nMagicPoint;
        public float nMagicDefence;
        public float nAccuracyRight;
        public float nAccuracyLeft;
        public float nMagicAccuracy;
        public float nAvoid;
        public float nMagicAvoid;
        public float nBlockChance;
        public float nMoveSpeed;
        public float nAttackSpeed;
        public float nAttackRange;
        public float nMaxWeight;
        public float nCastingSpeed;
        public float nCoolTimeSpeed;
        public float nItemChance;
        public float nHPRegenPercentage;
        public float nHPRegenPoint;
        public float nMPRegenPercentage;
        public float nMPRegenPoint;

    }

    public class CreatureAttributeServer : CreatureAtribute
    {
        public float nAttackSpeedRight;
        public float nAttackSpeedLeft;
        public float nDoubleAttackRatio;
        public float nStunResistance;
        public float nMoveSpeedDecreaseResistance;
        public float nHPAdd;
        public float nMPAdd;
        public float nHPAddByItem;
        public float nMPAddByItem;


        public void Reset(short v)
        {
            nCritical = v;
            nCriticalPower = v;
            nAttackPointRight = v;
            nAttackPointLeft = v;
            nDefence = v;
            nBlockDefence = v;
            nMagicPoint = v;
            nMagicDefence = v;
            nAccuracyRight = v;
            nAccuracyLeft = v;
            nMagicAccuracy = v;
            nAvoid = v; 
            nMagicAvoid = v;       
            nBlockChance = v;
            nMoveSpeed = v;
            nAttackSpeed = v;
            nAttackRange = v;
            nMaxWeight = v;
            nCastingSpeed = v;
            nCoolTimeSpeed = v;
            nItemChance = v;
            nHPRegenPercentage = v;
            nHPRegenPoint = v;
            nMPRegenPercentage = v;
            nMPRegenPoint = v;

            nAttackSpeedRight = v;
            nAttackSpeedLeft = v;  
            nDoubleAttackRatio = v;
            nStunResistance = v;   
            nMoveSpeedDecreaseResistance = v;
            nHPAdd = v;
            nMPAdd = v;
            nHPAddByItem = v;
            nMPAddByItem = v;
        }

        public void Copy(CreatureAttributeServer v)
        {
            nCritical = v.nCritical;
            nCriticalPower = v.nCriticalPower;
            nAttackPointRight = v.nAttackPointRight;
            nAttackPointLeft = v.nAttackPointLeft;
            nDefence = v.nDefence;
            nBlockDefence = v.nBlockDefence;
            nMagicPoint = v.nMagicPoint;
            nMagicDefence = v.nMagicDefence;
            nAccuracyRight = v.nAccuracyRight;
            nAccuracyLeft = v.nAccuracyLeft;
            nMagicAccuracy = v.nMagicAccuracy;
            nAvoid = v.nAvoid;
            nMagicAvoid = v.nMagicAvoid;
            nBlockChance = v.nBlockChance;
            nMoveSpeed = v.nMoveSpeed;
            nAttackSpeed = v.nAttackSpeed;
            nAttackRange = v.nAttackRange;
            nMaxWeight = v.nMaxWeight;
            nCastingSpeed = v.nCastingSpeed;
            nCoolTimeSpeed = v.nCoolTimeSpeed;
            nItemChance = v.nItemChance;
            nHPRegenPercentage = v.nHPRegenPercentage;
            nHPRegenPoint = v.nHPRegenPoint;
            nMPRegenPercentage = v.nMPRegenPercentage;
            nMPRegenPoint = v.nMPRegenPoint;

            nAttackSpeedRight = v.nAttackSpeedRight;
            nAttackSpeedLeft = v.nAttackSpeedLeft;
            nDoubleAttackRatio = v.nDoubleAttackRatio;
            nStunResistance = v.nStunResistance;
            nMoveSpeedDecreaseResistance = v.nMoveSpeedDecreaseResistance;
            nHPAdd = v.nHPAdd;
            nMPAdd = v.nMPAdd;
            nHPAddByItem = v.nHPAddByItem;
            nMPAddByItem = v.nMPAddByItem;
        }

        public void WriteToPacket(PacketOut packet)
        {
            packet.WriteInt16((short)(nCritical > 32000 ? 32000 : nCritical));
            packet.WriteInt16((short)(nCriticalPower > 32000 ? 32000 : nCriticalPower));
            packet.WriteInt16((short)(nAttackPointRight > 32000 ? 32000 : nAttackPointRight));
            packet.WriteInt16((short)(nAttackPointLeft > 32000 ? 32000 : nAttackPointLeft));
            packet.WriteInt16((short)(nDefence > 32000 ? 32000 : nDefence));
            packet.WriteInt16((short)(nBlockDefence > 32000 ? 32000 : nBlockDefence));
            packet.WriteInt16((short)(nMagicPoint > 32000 ? 32000 : nMagicPoint));
            packet.WriteInt16((short)(nMagicDefence > 32000 ? 32000 : nMagicDefence));
            packet.WriteInt16((short)(nAccuracyRight > 32000 ? 32000 : nAccuracyRight));
            packet.WriteInt16((short)(nAccuracyLeft > 32000 ? 32000 : nAccuracyLeft));
            packet.WriteInt16((short)(nMagicAccuracy > 32000 ? 32000 : nMagicAccuracy));
            packet.WriteInt16((short)(nAvoid > 32000 ? 32000 : nAvoid));
            packet.WriteInt16((short)(nMagicAvoid > 32000 ? 32000 : nMagicAvoid));
            packet.WriteInt16((short)(nBlockChance > 32000 ? 32000 : nBlockChance));
            packet.WriteInt16((short)(nMoveSpeed > 32000 ? 32000 : nMoveSpeed));
            packet.WriteInt16((short)(nAttackSpeedRight > 32000 ? 32000 : nAttackSpeedRight));
            packet.WriteInt16((short)(nAttackRange > 32000 ? 32000 : nAttackRange));
            packet.WriteInt32((int)nMaxWeight);
            packet.WriteInt16((short)(nCastingSpeed > 32000 ? 32000 : nCastingSpeed));
            packet.WriteInt16((short)(nCoolTimeSpeed > 32000 ? 32000 : nCoolTimeSpeed));
            packet.WriteInt16((short)(nItemChance > 32000 ? 32000 : nItemChance));
            packet.WriteInt16((short)(nHPRegenPercentage > 32000 ? 32000 : nHPRegenPercentage));
            packet.WriteInt16((short)(nHPRegenPoint > 32000 ? 32000 : nHPRegenPoint));
            packet.WriteInt16((short)(nMPRegenPercentage > 32000 ? 32000 : nMPRegenPercentage));
            packet.WriteInt16((short)(nMPRegenPoint > 32000 ? 32000 : nMPRegenPoint));
            packet.WriteInt16(0); //packet.WriteInt16(nPerfectBlock);
            packet.WriteInt16(0); //packet.WriteInt16(nIgnoreMDef);
            packet.WriteInt16(0); //packet.WriteInt16(nIgnoreMDefPercent);
            packet.WriteInt16(0); //packet.WriteInt16(nIgnorePDef);
            packet.WriteInt16(0); //packet.WriteInt16(nIgnorePDefPercent);
            packet.WriteInt16(0); //packet.WriteInt16(nPenetrateMagical);
            packet.WriteInt16(0); //packet.WriteInt16(nPenetrateMagicalPercent);
            packet.WriteInt16(0); //packet.WriteInt16(nPenetrate);
            packet.WriteInt16(0); //packet.WriteInt16(nPenetratePercent);
        }
    }
}
